#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, m;
int a[N];
bool equal(vector<pii>& a, vector<pii>& b) {
  if (a.size() != b.size()) return false;
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  rep(i, 0, a.size() - 1) {
    if (a[i] != b[i]) return false;
  }
  return true;
}
void solve() {
  vector<pii> a, b;
  rep(i, 1, n) {
    int x, y;
    cin >> x >> y;
    if (x < y)
      a.push_back(pii(x, y));
    else
      b.push_back(pii(y, x));
  }
  if (equal(a, b))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  while (cin >> n && n) solve();
  return 0;
}